package com.retail.team.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.team.entity.request.RetailTeamAddSpRequest;
import com.retail.team.entity.vo.RetailTeamAddSpVo;
import com.retail.team.service.RetailTeamAddSpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 团队审核 API
* @author Administrator
*/
@Api(tags = "团队审核 API")
@RestController
@RequestMapping("/retailTeamAddSp")
public class RetailTeamAddSpController extends AbstractCommonController<RetailTeamAddSpService, RetailTeamAddSpRequest, RetailTeamAddSpVo> {

    @Autowired
    private RetailTeamAddSpService retailTeamAddSpService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(retailTeamAddSpService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存团队审核")
    public Result<Integer> save(@RequestBody RetailTeamAddSpRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(retailTeamAddSpService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新团队审核")
    public Result<Integer> update(@RequestBody RetailTeamAddSpRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(retailTeamAddSpService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("团队审核-查询")
    public Result<List<RetailTeamAddSpVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(retailTeamAddSpService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("团队审核-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(retailTeamAddSpService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("团队审核-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<RetailTeamAddSpRequest> req) {
        return super.page(retailTeamAddSpService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除团队审核")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(retailTeamAddSpService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除团队审核")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(retailTeamAddSpService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
